package com.google.code.syncgear.util;

import java.util.logging.Logger;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public final class MessageUtil {

	private static final Logger log = Logger.getLogger(MessageUtil.class.getName());

	private static Configuration configuration;
	
	public static String contact(String title, Object value) {
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append(title);
		stringBuffer.append(":");
		stringBuffer.append(value);
		return stringBuffer.toString();
	}

	public static String get(String key) {
		String message = "";
		if(configuration == null) {
			load();
			if(configuration != null) {
				String tmp = configuration.getString(key);
				if(tmp != null) {
					message = tmp;
				}
			}				
		}
		return message;
	}
	
	private static void load() {
		try {
			configuration = new PropertiesConfiguration("message.properties");
		} catch (ConfigurationException e) {
			e.printStackTrace();
			log.severe("can't load message properties.");
		}
	}

}
